<template>
  <div class="container">
    <div class="crumbs"></div>
    <div class="section">
      <div class="filter-top-tab">
        <ul>
          <li class="li1"><span>招聘职位</span></li>
          <li class="li2"><span>招聘简历</span></li>
        </ul>
      </div>
      <form id="listing-filter" class="compact-open">
        <fieldset>
          <span class="legend">招聘</span>
          <div class="links" style="height: auto">
            <a @click="getPosition(item)" v-for="item in PositionData" :key="item" >{{ item }}</a>
          </div>
        </fieldset>
        <fieldset>
          <span class="legend">薪资水平</span>
          <div class="links" style="height: 26px">
            <a v-for="item in salary" :key="item" >{{ item }}</a>
          </div>
        </fieldset>
        <fieldset>
          <span class="legend">福利待遇</span>
          <div class="links" style="height: 26px"></div>
        </fieldset>
        <fieldset>
          <span class="legend">地区</span>
          <div class="links" style="height: 26px"></div>
        </fieldset>
        <fieldset>
          <input
            class="fieldset-input"
            placeholder="搜索职位或企业"
            type="text"
          />
        </fieldset>
      </form>
    </div>
    <div class="main">
      <section class="tab-sort-nav"></section>
      <div id="all-list" class="section-apply-list">
        <ul style="border-top: 1px solid #eee" class="table-view">
          <li class="list-head">
            <h4>百姓优选专区</h4>
            <span class="list-head-text">百姓优选先行赔付，找工作有保障</span>
          </li>
          <li  v-for="item in list" :key="item.title" class="list">
            <input type="checkbox" data-apply="" class="checkbox" />
            <div class="table-view-body-job-list">
              <div class="preview-hover">
                <a
                  href=""
                  rel=""
                  target="_blank"
                  class="ad-title"
                  >{{ item.title }}</a
                >
                <a
                  href="//beijing.baixing.com/siji/"
                  target="_blank"
                  class="tag tag-category"
                  >{{ item.position }}</a
                >
                <a
                  data-toggle="tooltip"
                  data-placement="top"
                  data-original-title="直招岗位"
                  class="tag tag-zhizhao"
                  >{{ item.tab }}</a
                >
                <a
                  data-toggle="tooltip"
                  data-placement="top"
                  data-original-title="优选保障岗位"
                  class="tag tag-preferred-guarantee"
                >
                </a>
              </div>
              <span class="salary">{{ item.salary }}</span>
            </div>
            <div class="table-view-body-small">
              <div class="table-view-cap-job-list">
                <span class="separator"></span>{{ item.describe }}
              </div>
              <div class="wellfares-badges">
                <label class="tag-tag-job">年底双薪</label
                ><label class="tag-tag-job">员工体检</label
                ><label class="tag-tag-job">包吃</label>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <div class="listing-pager-section">
        <el-pagination background layout="prev, pager, next" :total="this.total" @current-change="handleCurrentChange">
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import { getPositonData } from "../api/getPositionData";
import { getList } from "../api/getListData";
export default {
  name: "headMiddle",
  data() {
    return {
      token: "",
      PositionData: "",
      salary: "",
      total:'',
      param: {
        position: "all",
        page: 1,
        pageSize: 10,
      },
      list: "",
    };
  },
  computed: {},
  watch: {},
  methods: {
    getPositonData() {
      getPositonData("获取标题栏信息")
        .then(({ data: res }) => {
          // console.log(res);
          this.PositionData = res.data.position;
          //   console.log(res.data.position);
          this.salary = res.data.salary;
          this.getlist()
        })
        .catch((err) => {
          console.log("请求错误", err);
        });
    },
    getlist() {
      var params = {
        position: this.param.position,
        page: this.param.page,
        pageSize: this.param.pageSize,
      };
      getList(params)
        // .then(({data: res})=>{
        //   console.log(res);
        // })
        .then(({ data: res }) => {
          console.log(res);
          this.list = res.data;
          this.total= res.total
        })
        .catch((err) => {
          console.error(new Error(err.message));
        });
    },
    getPosition(val){
      // console.log(val);
      this.param.position = val
      // console.log(this.param.position);
      this.getlist()
    },
    handleCurrentChange(val){
      // console.log(val);
      this.param.page = val
      this.getlist();
       

    }
  },
  created() {
    //   页面加载时就从本地通过localstorage获取储存的token值
    // this.token = localStorage.getItem('token')
    // console.log(this.token);
  },
  mounted() {
    this.getPositonData();
    // this.getlist();
  },
  destroyed() {},
  activated() {},
};
</script>
<style lang="scss" scoped>
.container {
  box-sizing: border-box;
  height: 80%;
  background-color: #eeeff1;
  .crumbs {
    height: 15px;
    // margin: 18px auto;
    // background-color: pink;
  }
  .section {
    box-sizing: border-box;
    .filter-top-tab {
      // display: flex;
      margin: 20px auto 0;
      background: #fff;
      border: 1px solid #ddd;
      height: 37px;
      width: 1200px;
      max-width: 1200px;
      box-sizing: border-box;

      ul {
        box-sizing: border-box;

        height: 36px;
        font-size: 16px;
        background: #ededed;
        .li1 {
          float: left;
          margin: 0;
          box-sizing: border-box;
          background: #fff;

          span {
            position: relative;
            color: #000;
            background: #fff;
            line-height: 36px;
            padding: 0 15px;
          }
        }
        .li2 {
          float: left;
          margin: 0;
          box-sizing: border-box;
          span {
            display: inline-block;
            padding: 0 15px;
            line-height: 36px;
            color: #999;
            text-decoration: none;
          }
        }
      }
    }
    .compact-open {
      box-sizing: border-box;
      width: 1200px;
      max-width: 1200px;
      margin-top: 0;
      font-size: 12px;
      margin-left: auto;
      margin-right: auto;
      border: 1px solid #ddd;
      border-top: none;
      fieldset {
        border: none;
        background: #fff;
        padding: 0 1em;
        margin: 0;
        // height: 10px;
        height: auto;
      }
      .legend {
        float: left;
        // display: inline-block;
        padding: 0.5em 0;
        margin: 0.5em 0;
        border: 1px solid transparent;
        line-height: 1;
        color: #666;
        font-weight: 700;
      }
      .links {
        display: flex;
        flex-wrap: wrap;
        width: 90%;
        overflow: hidden;
        height: auto;
        margin: 0.5em 0.5em 0.5em 6em;
        a {
          color: #333;
          display: inline-block;
          padding: 0.5em;
          border: 1px solid transparent;
          line-height: 1;
          height: auto;
          // a:hover{text-decoration:overline; }
        }
        a:hover {
          text-decoration: underline;
          cursor: pointer;
        }
      }
      .fieldset-input {
        width: 280px;
        padding: 5px;
        color: #333;
        border: 1px solid #ddd;
        margin-bottom: 15px;
        margin-top: 10px;
        float: left;
      }
    }
  }
  .main {
    background-color: #eeeff1;
    padding-left: 136.435px;
    .tab-sort-nav {
      height: 50px;
      background-color: #FFFFFF;
      border: 1px solid rgb(208, 208, 208);
      margin-top: 20px;
      width: 1200px;
      min-width: 1200px;
      box-sizing: border-box;
    }
    .section-apply-list {
      height: 100%;
      background-color: #ffffff;
      margin-top: 10px;
      width: 1000px;
      min-width: 1000px;
      box-sizing: border-box;
      border: 1px solid rgb(208, 208, 208);
      .table-view {
        // height: 300px;
        .list-head {
          border-top: #eee 1px solid;
          display: flex;
          height: 60px;
          justify-content: space-between;
          line-height: 26px;
          padding: 0px 10px 0px 50px;
          border-bottom: 1px #cecece dashed;
          h4 {
            display: inline-block;
            height: 35%;
            padding-left: 30px;
            margin-left: -30px;
            font-size: 18px;
            border-left: 5px solid #f46;
          }
          .list-head-text {
            padding-top: 20px;
          }
        }
        .list {
          position: relative;
          border-bottom: 1px #cecece dashed;
          padding: 10px 20px 10px 50px;
          .table-view-body-job-list {
            display: flex;
            justify-content: space-between;
            width: 100%;
            margin-bottom: 5px;
            margin-top: 5px;
            .preview-hover {
              a {
                color: #000;
              }
              a:hover {
                text-decoration: underline;
                color: rgb(236, 9, 9);
              }
            }
            .salary {
              color: #f46;
              font-size: 18px;
              font-weight: 700;
              padding-top: 7px;
            }
          }
          .table-view-body-small {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0px;
            .table-view-cap-job-list {
              color: #999;
              font-size: 14px;
            }
            .wellfares-badges {
              font-size: 14px;
              max-width: 40%;
              padding: 6px 0;
              .tag-tag-job {
                color: #999;
                border: 1px solid #bebebe;
                line-height: 15px;
                padding: 0.25em;
                margin-right: 0.1em;
                border-radius: 2px;
              }
            }
          }
          .checkbox {
            position: absolute;
            top: 40%;
            left: 20px;
          }
        }
      }
    }
    .listing-pager-section {
      padding-left: 300px;
      display: flex;
      height: 50px;
      margin-top: 10px;
      margin-bottom: 10px;
    }
  }
}
</style>

